// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('ionicApp', ['ionic', 'ionicApp.controllers'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider) {

	$stateProvider
		.state('signin', {
			url: "/sign-in",
			templateUrl: "sign-in.html",
			controller: 'SignInCtrl'
		})
		.state('forgotpassword', {
			url: "/forgot-password",
			templateUrl: "forgot-password.html"
		})
		.state('app', {
			url: "/app",
			abstract: true,
			templateUrl: "menu.html"
		})
		.state('app.home', {
			url: "/home",
			views: {
				'menuContent': {
					templateUrl: "home.html",
					controller: 'HomeCtrl'
				}
			}
		})
		.state('app.all_business', {
			url: "/all_business",
			views: {
				'menuContent' :{
					templateUrl: "all_business.html",
					controller: 'AllBusinessCtrl'
				}
			}
		})
		.state('app.preferential_list', {
			url: "/preferential_list",
			views: {
				'menuContent' :{
					templateUrl: "preferential_list.html",
					controller: 'PreferentialListCtrl'
				}
			}
		})
		.state('app.search_list', {
			url: "/search_list/:business_category_id",
			views: {
				'menuContent' :{
					templateUrl: "search_list.html",
					controller: 'SearchListCtrl'
				}
			}
		})
		.state('app.merchant_view', {
			url: "/merchant_view/:id",
			views: {
				'menuContent' :{
					templateUrl: "merchant_view.html",
					controller: 'MerchantViewCtrl'
				}
			}
		})

		.state('app.facts', {
			url: "/facts",
			views: {
				'menuContent': {
					templateUrl: "facts.html"
				}
			}
		})
		.state('app.facts2', {
			url: "/facts2",
			views: {
				'menuContent': {
					templateUrl: "facts2.html"
				}
			}
		})
		.state('app.about', {
			url: "/about",
			views: {
				'menuContent': {
					templateUrl: "about.html"
				}
			}
		})
		.state('app.playtlist', {
			url: "/playtlist",
			views: {
				'menuContent': {
					templateUrl: "playtlist.html",
					controller: 'playtlist'
				}
			}
		})
		.state('app.contact', {
			url: "/contact",
			views: {
				'menuContent': {
					templateUrl: "contact.html"
				}
			}
		})






	if(storage.getItem('id')){
		$urlRouterProvider.otherwise("/app/home");
	}else{
		$urlRouterProvider.otherwise("/sign-in");
	}


});

